#ifndef __AMF_H__
#define __AMF_H__

#include "um_basic_types.h"
#include "umapi_os_list.h"
#include <assert.h>

typedef enum  {
	AMF_NUMBER,
	AMF_INTEGER,
	AMF_BOOLEAN,
	AMF_STRING,
	AMF_OBJECT,
	AMF_NULL,
	AMF_UNDEFINED,
	AMF_ECMA_ARRAY,
}AMFType ;

enum {
	AMF0_NUMBER,
	AMF0_BOOLEAN,
	AMF0_STRING,
	AMF0_OBJECT,
	AMF0_MOVIECLIP,
	AMF0_NULL,
	AMF0_UNDEFINED,
	AMF0_REFERENCE,
	AMF0_ECMA_ARRAY,
	AMF0_OBJECT_END,
	AMF0_STRICT_ARRAY,
	AMF0_DATE,
	AMF0_LONG_STRING,
	AMF0_UNSUPPORTED,
	AMF0_RECORD_SET,
	AMF0_XML_OBJECT,
	AMF0_TYPED_OBJECT,
	AMF0_SWITCH_AMF3,
};

enum {
	AMF3_UNDEFINED,
	AMF3_NULL,
	AMF3_FALSE,
	AMF3_TRUE,
	AMF3_INTEGER,
	AMF3_NUMBER,
	AMF3_STRING,
	AMF3_LEGACY_XML,
	AMF3_DATE,
	AMF3_ARRAY,
	AMF3_OBJECT,
	AMF3_XML,
	AMF3_BYTE_ARRAY,
};


typedef struct
{
	struct umapi_list_head head;
}amf_object_t;

typedef struct AMFValue
{
	AMFType m_type;
	union {
		UM_CHAR *string;
		UM_DOUBLE number;
		UM_S32 integer;
		UM_BOOL boolean;
		amf_object_t *object;
	} m_value;
	UM_CHAR * (*as_string)(struct AMFValue *value);
	UM_DOUBLE (*as_number)(struct AMFValue *value);
	UM_DOUBLE (*as_integer)(struct AMFValue *value);
	UM_BOOL (*as_bool)(struct AMFValue *value);
	AMFType (*type)(struct AMFValue *value);
	UM_VOID (*clear)(struct AMFValue *value);
	amf_object_t * (*as_object)(struct AMFValue *value);
	UM_VOID (*get)(struct AMFValue * ptr, AMFType t, UM_CHAR *k ,UM_VOID* value);
	UM_VOID (*set)(struct AMFValue * ptr, AMFType t, UM_CHAR *k ,UM_VOID* value);
	UM_VOID (*free)(struct AMFValue * value);
}AMFValue;

typedef struct
{
	UM_CHAR *first;
	AMFValue *second;
	struct umapi_list_head head;
}AMFObject;

AMFValue* AMFValueFromDefault(AMFType type);
AMFValue* AMFValueFromChar(UM_CHAR *s);
AMFValue* AMFValueFromDouble(UM_DOUBLE n);
AMFValue* AMFValueFromInt(UM_S32 i);
AMFValue* AMFValueFromBool(UM_BOOL b);
AMFValue* AMFValueFromObject(amf_object_t* object);
AMFValue* AMFValueClone(AMFValue * from);

#endif

